package com.hrp.controller;

import com.hrp.domain.ResponseData;
import com.hrp.domain.TransportRecord;
import com.hrp.service.TransportRecordQueryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * Created by Administrator on 2019-04-29.
 */
@RestController
@RequestMapping("transprotRecordQuery")
public class TransportRecordQueryController {

    @Autowired
    private TransportRecordQueryService transportRecordQueryService;



    @RequestMapping("/getTransportRecordByPage")
    public Map<String,Object> getTransportRecordByPage(Integer page, Integer rows, @RequestParam(name = "sort", defaultValue = "id") String sort  ,
                                                       @RequestParam(name = "order", defaultValue = "asc") String order,
                                                       @RequestParam(name = "sendTimeKsrq", defaultValue = "2018-01-01") String sendTimeKsrq,
                                                       @RequestParam(name = "sendTimeJsrq", defaultValue = "2018-01-01") String sendTimeJsrq,
                                                       @RequestParam(name = "varietiesIdStr", defaultValue = "1") String varietiesIdStr,
                                                       @RequestParam(name = "supplierIdStr", defaultValue = "-1") String supplierIdStr,
                                                       @RequestParam(name = "receiverIdStr", defaultValue = "-1") String receiverIdStr) {
//        Map<String, Object> jsonMap = new HashMap<String, Object>();//定义map
//        List<Jxkhzq> list =  jxkhzqService.getAllKhzq();
//        jsonMap.put("total", list.size());//total键 存放总记录数，必须的
//        jsonMap.put("rows", list);//rows键 存放每页记录 list

        return transportRecordQueryService.getTransportRecordByPage(page,rows,sort,order,sendTimeKsrq,sendTimeJsrq,varietiesIdStr,supplierIdStr,receiverIdStr);
    }

    @RequestMapping("/getTransportRecordByPageSummary")
    public Map<String,Object> getTransportRecordByPageSummary(Integer page, Integer rows, @RequestParam(name = "sort", defaultValue = "receiverId") String sort  ,
                                                       @RequestParam(name = "order", defaultValue = "asc") String order,
                                                       @RequestParam(name = "sendTimeKsrq", defaultValue = "2018-01-01") String sendTimeKsrq,
                                                       @RequestParam(name = "sendTimeJsrq", defaultValue = "2018-01-01") String sendTimeJsrq,
                                                              @RequestParam(name = "varietiesIdStr", defaultValue = "1") String varietiesIdStr,
                                                       @RequestParam(name = "supplierIdStr", defaultValue = "-1") String supplierIdStr,
                                                       @RequestParam(name = "receiverIdStr", defaultValue = "-1") String receiverIdStr) {

        return transportRecordQueryService.getTransportRecordByPageSummary(page,rows,sort,order,sendTimeKsrq,sendTimeJsrq,varietiesIdStr,supplierIdStr,receiverIdStr);
    }




}
